package com.hzsai.rabbitmq;

import com.hzsai.pojo.User;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * hzsai 2019/8/1
 * usage: RabbitMQ message consumer
 **/
@Component
public class RabbitMQMessageReceiver {

    /**
     * RabbitMQ监听着rabbitmq.queue.msg队列
     * @param msg
     */
    @RabbitListener(queues = "${rabbitmq.queue.msg}")
    public void receiveMsg(String msg) {
        System.out.println("【" + " Pojo"+ "】");
        System.out.println(msg);
    }

    /**
     * RabbitMQ监听着rabbitmq.queue.user队列
     * @param user
     */
    @RabbitListener(queues = "${rabbitmq.queue.user}")
    public void receiveUser(User user) {
        System.out.println("【" + " UserObject"+ "】");
        System.out.println(user.toString());
    }
}
